﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business.Dal;
using Business.Entity;

namespace Sahibinden.UserAction
{
    public partial class MesajEkle : System.Web.UI.Page
    {
        Ilan ilan;
        Uye uye;
        Uye alici;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString.Get("IlanID") == null)
            {
                Response.End();
            }

     
                string IlanID = Request.QueryString.Get("IlanID");
                string GonderenID = Page.User.Identity.Name;
                UyeProvider uyep = new UyeProvider();
                uye = uyep.GetUyeGetirID(Convert.ToInt32(GonderenID));
                IlanProvider ip = new IlanProvider();
                ilan = ip.GetIlanByIlanID(Convert.ToInt32(IlanID));
                string AliciID = ilan.UyeID.ToString();
                alici = uyep.GetUyeGetirID(ilan.UlkeID);
                
                lbAlici.Text = alici.Adi + " " + alici.Soyadi;
                lbGonderen.Text = uye.Adi + " " + uye.Soyadi;
                lbilan.Text = ilan.IlanBasligi + " #(" + ilan.IlanID.ToString().PadLeft(10,'0') + ")";
                lbilan.PostBackUrl = "~/UserAction/IlaniListele.aspx?IlanID=" + ilan.IlanID.ToString();
          



        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            MesajProvider mp = new MesajProvider();
            Mesaj m = new Mesaj(uye.UyeID, alici.UyeID, "", txtMesaj.Text, false, false, false, ilan.IlanID);
            if (mp.Insert(m))
            {
                Response.Redirect("MesajOku.aspx");
            }
        }
    }
}
